package com.ling.pl.autoproject.definition.dao;

import com.ling.pl.autoproject.definition.model.ProjectEntity;
import com.ling.pl.core.commons.support.DaoPage;
import com.ling.pl.core.dao.impl.BaseDao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author bo.wang
 */
public abstract class BaseProjectDao extends BaseDao {

    public static final String BEAN_ID = "projectDao";

    public DaoPage findProjectByParams(Map params, Integer pageIndex, Integer pageSize) {
        StringBuffer query = new StringBuffer();
        Map values = new HashMap();
        buildProjectQuery(query, values, params);
        return pageBy(query, values, pageIndex, pageSize);
    }

    public List<ProjectEntity> findProjectByParams(Map params) {
        StringBuffer query = new StringBuffer();
        Map values = new HashMap();
        buildProjectQuery(query, values, params);
        return findBy(query, values);
    }

    protected abstract void buildProjectQuery(StringBuffer query, Map values, Map params);
}

